package com.buiminhthang.food.net;

import org.json.JSONArray;
import org.json.JSONObject;


public class HttpResult {
	private int result_code;
	private String result_msg;
	private String data;
	
	public HttpResult(int code, String msg, String data) {
		this.result_code = code;
		this.result_msg = msg;
		this.data = data;
	}
	
	public static HttpResult fromJson(String json) {
		try {
			JSONObject jo = new JSONObject(json);
			JSONArray ja = jo.getJSONArray("data");
			int code = jo.getInt("result_code");
			String msg = jo.getString("message");
			String data = ja.toString();
			return new HttpResult(code, msg, data);
		} catch (Exception ex) {
			return null;
		}
	}

	public int getResultCode() {
		return result_code;
	}

	public String getResultMsg() {
		return result_msg;
	}

	public String getData() {
		return data;
	}

}